/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ComExWeb.ui.beans;

import ComExWeb.dominio.bolao.Rodada;
import ComExWeb.dominio.bolao.Rodada;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author 002824992500
 */
@ManagedBean
@ViewScoped
public class ApostaJsfBean extends BaseCRUDJSFBean {

    private static final Logger log = LoggerFactory.getLogger(ApostaJsfBean.class);
    private String field;
    private Rodada rodada;
    
    public Rodada getRodada() {
        return getObjSelecionado();
    }

    public void setRodada(Rodada rodada) {
        setObjSelecionado(rodada);
    }

    private List<Rodada> rodadas = new ArrayList<Rodada>();

    public List<Rodada> getRodadas() {
        return rodadas;
    }

    /** Creates a new instance of ColaboradorJSFBean */
    public ApostaJsfBean() {
    }

    @Override
    public void setup() {   
        
        setField("ui-icon ui-icon-flag");
        setRodada((Rodada)getCrudService().executeQuerySingleResult("select r from Rodada r where r.virgente", "S"));

        try {
            setPaginaForm("form_rodada");
            setPaginaListagem("list_rodada");
            setCrudClass(Rodada.class);

            renovarTabela();

        } catch (Exception e) {
            String err = "Erro na inicialização: " + e.getMessage();
            error(err);
            log.error(err, e);
        }
    }

    @Override
    protected void renovarTabela() {        
        this.rodadas = getCrudService().findAll(Rodada.class);
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

}
